{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b6833516",
   "metadata": {},
   "source": [
    "--------------------------------------------\n",
    " > 2022/09/06\n",
    " \n",
    " > python课堂"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "950dbc9e",
   "metadata": {},
   "source": [
    "## 1.回顾变量的概念"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ec9f1aad",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新_01_ID = \"2110130093\"\n",
    "网新_02_ID = \"2110130090\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d6aaa815",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2110130090'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_02_ID"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4aa70cdf",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新_01_ID = \"19\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c5b67128",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'19'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_01_ID"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1194ad2a",
   "metadata": {},
   "source": [
    "## 2.条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e3b67246",
   "metadata": {},
   "outputs": [],
   "source": [
    "# wday = 0 1 2 3 4 5 0-5(星期一-星期日)\n",
    "import time\n",
    "\n",
    "wday = time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c2d8585f",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_hour = time.localtime().tm_hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4b25eb44",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_min = time.localtime().tm_min"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a9b04235",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天没有python课\n"
     ]
    }
   ],
   "source": [
    "if wday != 1:\n",
    "    print(\"今天没有python课\")\n",
    "elif time_hour == 12 and time_min > 50:\n",
    "    print(\"正在上python课，刚上课\")\n",
    "elif time_hour == 13:\n",
    "    print(\"大概第二节\")\n",
    "elif time_hour == 14:\n",
    "    print(\"还在上，2点了\")\n",
    "elif time_hour == 15:\n",
    "    print(\"坚持一下\")\n",
    "elif time_hour == 16 and time_min < 50:\n",
    "    print(\"快下课了\")\n",
    "else:\n",
    "    print(\"今天有python课，上课时间为xxxxxx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "800d17e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "94182f60",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "for ch in\"Hi!\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "646fd6d4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e644a9fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n",
      "7\n",
      "9\n",
      "1\n",
      "2\n",
      "1\n",
      "9\n",
      "3\n",
      "8\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(10):\n",
    "    print(random.randint(1,9))\n",
    "     "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "7216dbd7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles hhda\n",
      "99 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "98 bottles da\n",
      "98 bottles hhda\n",
      "98 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "97 bottles da\n",
      "97 bottles hhda\n",
      "97 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "96 bottles da\n",
      "96 bottles hhda\n",
      "96 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "95 bottles da\n",
      "95 bottles hhda\n",
      "95 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "94 bottles da\n",
      "94 bottles hhda\n",
      "94 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "93 bottles da\n",
      "93 bottles hhda\n",
      "93 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "92 bottles da\n",
      "92 bottles hhda\n",
      "92 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "91 bottles da\n",
      "91 bottles hhda\n",
      "91 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "90 bottles da\n",
      "90 bottles hhda\n",
      "90 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "89 bottles da\n",
      "89 bottles hhda\n",
      "89 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "88 bottles da\n",
      "88 bottles hhda\n",
      "88 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "87 bottles da\n",
      "87 bottles hhda\n",
      "87 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "86 bottles da\n",
      "86 bottles hhda\n",
      "86 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "85 bottles da\n",
      "85 bottles hhda\n",
      "85 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "84 bottles da\n",
      "84 bottles hhda\n",
      "84 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "83 bottles da\n",
      "83 bottles hhda\n",
      "83 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "82 bottles da\n",
      "82 bottles hhda\n",
      "82 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "81 bottles da\n",
      "81 bottles hhda\n",
      "81 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "80 bottles da\n",
      "80 bottles hhda\n",
      "80 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "79 bottles da\n",
      "79 bottles hhda\n",
      "79 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "78 bottles da\n",
      "78 bottles hhda\n",
      "78 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "77 bottles da\n",
      "77 bottles hhda\n",
      "77 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "76 bottles da\n",
      "76 bottles hhda\n",
      "76 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "75 bottles da\n",
      "75 bottles hhda\n",
      "75 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "74 bottles da\n",
      "74 bottles hhda\n",
      "74 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "73 bottles da\n",
      "73 bottles hhda\n",
      "73 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "72 bottles da\n",
      "72 bottles hhda\n",
      "72 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "71 bottles da\n",
      "71 bottles hhda\n",
      "71 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "70 bottles da\n",
      "70 bottles hhda\n",
      "70 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "69 bottles da\n",
      "69 bottles hhda\n",
      "69 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "68 bottles da\n",
      "68 bottles hhda\n",
      "68 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "67 bottles da\n",
      "67 bottles hhda\n",
      "67 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "66 bottles da\n",
      "66 bottles hhda\n",
      "66 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "65 bottles da\n",
      "65 bottles hhda\n",
      "65 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "64 bottles da\n",
      "64 bottles hhda\n",
      "64 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "63 bottles da\n",
      "63 bottles hhda\n",
      "63 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "62 bottles da\n",
      "62 bottles hhda\n",
      "62 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "61 bottles da\n",
      "61 bottles hhda\n",
      "61 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "60 bottles da\n",
      "60 bottles hhda\n",
      "60 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "59 bottles da\n",
      "59 bottles hhda\n",
      "59 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "58 bottles da\n",
      "58 bottles hhda\n",
      "58 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "57 bottles da\n",
      "57 bottles hhda\n",
      "57 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "56 bottles da\n",
      "56 bottles hhda\n",
      "56 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "55 bottles da\n",
      "55 bottles hhda\n",
      "55 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "54 bottles da\n",
      "54 bottles hhda\n",
      "54 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "53 bottles da\n",
      "53 bottles hhda\n",
      "53 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "52 bottles da\n",
      "52 bottles hhda\n",
      "52 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "51 bottles da\n",
      "51 bottles hhda\n",
      "51 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "50 bottles da\n",
      "50 bottles hhda\n",
      "50 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "49 bottles da\n",
      "49 bottles hhda\n",
      "49 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "48 bottles da\n",
      "48 bottles hhda\n",
      "48 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "47 bottles da\n",
      "47 bottles hhda\n",
      "47 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "46 bottles da\n",
      "46 bottles hhda\n",
      "46 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "45 bottles da\n",
      "45 bottles hhda\n",
      "45 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "44 bottles da\n",
      "44 bottles hhda\n",
      "44 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "43 bottles da\n",
      "43 bottles hhda\n",
      "43 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "42 bottles da\n",
      "42 bottles hhda\n",
      "42 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "41 bottles da\n",
      "41 bottles hhda\n",
      "41 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "40 bottles da\n",
      "40 bottles hhda\n",
      "40 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "39 bottles da\n",
      "39 bottles hhda\n",
      "39 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "38 bottles da\n",
      "38 bottles hhda\n",
      "38 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "37 bottles da\n",
      "37 bottles hhda\n",
      "37 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "36 bottles da\n",
      "36 bottles hhda\n",
      "36 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "35 bottles da\n",
      "35 bottles hhda\n",
      "35 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "34 bottles da\n",
      "34 bottles hhda\n",
      "34 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "33 bottles da\n",
      "33 bottles hhda\n",
      "33 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "32 bottles da\n",
      "32 bottles hhda\n",
      "32 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "31 bottles da\n",
      "31 bottles hhda\n",
      "31 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "30 bottles da\n",
      "30 bottles hhda\n",
      "30 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "29 bottles da\n",
      "29 bottles hhda\n",
      "29 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "28 bottles da\n",
      "28 bottles hhda\n",
      "28 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "27 bottles da\n",
      "27 bottles hhda\n",
      "27 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "26 bottles da\n",
      "26 bottles hhda\n",
      "26 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "25 bottles da\n",
      "25 bottles hhda\n",
      "25 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "24 bottles da\n",
      "24 bottles hhda\n",
      "24 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "23 bottles da\n",
      "23 bottles hhda\n",
      "23 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "22 bottles da\n",
      "22 bottles hhda\n",
      "22 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "21 bottles da\n",
      "21 bottles hhda\n",
      "21 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "20 bottles da\n",
      "20 bottles hhda\n",
      "20 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "19 bottles da\n",
      "19 bottles hhda\n",
      "19 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "18 bottles da\n",
      "18 bottles hhda\n",
      "18 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "17 bottles da\n",
      "17 bottles hhda\n",
      "17 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "16 bottles da\n",
      "16 bottles hhda\n",
      "16 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "15 bottles da\n",
      "15 bottles hhda\n",
      "15 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "14 bottles da\n",
      "14 bottles hhda\n",
      "14 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "13 bottles da\n",
      "13 bottles hhda\n",
      "13 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "12 bottles da\n",
      "12 bottles hhda\n",
      "12 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "11 bottles da\n",
      "11 bottles hhda\n",
      "11 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "10 bottles da\n",
      "10 bottles hhda\n",
      "10 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "9 bottles da\n",
      "9 bottles hhda\n",
      "9 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "8 bottles da\n",
      "8 bottles hhda\n",
      "8 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "7 bottles da\n",
      "7 bottles hhda\n",
      "7 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "6 bottles da\n",
      "6 bottles hhda\n",
      "6 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "5 bottles da\n",
      "5 bottles hhda\n",
      "5 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "4 bottles da\n",
      "4 bottles hhda\n",
      "4 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "3 bottles da\n",
      "3 bottles hhda\n",
      "3 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "2 bottles da\n",
      "2 bottles hhda\n",
      "2 bottles hhhda\n",
      "ggda\n",
      "gggda\n",
      "1 jjda da\n",
      "1 jjda hhda\n",
      "1 jjda hhhda\n",
      "ggda\n",
      "gggda\n",
      "jjjda\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num, word,\"hhda\")\n",
    "    print(beer_num, word,\"hhhda\")\n",
    "    print(\"ggda\")\n",
    "    print(\"gggda\")\n",
    "    if beer_num == 1:\n",
    "        print(\"jjjda\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word =\"jjda\"\n",
    "        print(new_num, word, \"da\")\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5f012510",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/ztb/index0.htm\n",
      "https://www.nfu.edu.cn/ztb/index1.htm\n",
      "https://www.nfu.edu.cn/ztb/index2.htm\n",
      "https://www.nfu.edu.cn/ztb/index3.htm\n",
      "https://www.nfu.edu.cn/ztb/index4.htm\n",
      "https://www.nfu.edu.cn/ztb/index5.htm\n",
      "https://www.nfu.edu.cn/ztb/index6.htm\n",
      "https://www.nfu.edu.cn/ztb/index7.htm\n",
      "https://www.nfu.edu.cn/ztb/index8.htm\n",
      "https://www.nfu.edu.cn/ztb/index9.htm\n",
      "https://www.nfu.edu.cn/ztb/index10.htm\n",
      "https://www.nfu.edu.cn/ztb/index11.htm\n",
      "https://www.nfu.edu.cn/ztb/index12.htm\n",
      "https://www.nfu.edu.cn/ztb/index13.htm\n",
      "https://www.nfu.edu.cn/ztb/index14.htm\n",
      "https://www.nfu.edu.cn/ztb/index15.htm\n",
      "https://www.nfu.edu.cn/ztb/index16.htm\n",
      "https://www.nfu.edu.cn/ztb/index17.htm\n",
      "https://www.nfu.edu.cn/ztb/index18.htm\n",
      "https://www.nfu.edu.cn/ztb/index19.htm\n",
      "https://www.nfu.edu.cn/ztb/index20.htm\n",
      "https://www.nfu.edu.cn/ztb/index21.htm\n",
      "https://www.nfu.edu.cn/ztb/index22.htm\n",
      "https://www.nfu.edu.cn/ztb/index23.htm\n",
      "https://www.nfu.edu.cn/ztb/index24.htm\n",
      "https://www.nfu.edu.cn/ztb/index25.htm\n",
      "https://www.nfu.edu.cn/ztb/index26.htm\n"
     ]
    }
   ],
   "source": [
    "中大南方_招投标 = \"https://www.nfu.edu.cn/ztb/index.htm\"\n",
    "for page in range(27):\n",
    "    print(\"https://www.nfu.edu.cn/ztb/index\" + str(page) + \".htm\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "09208447",
   "metadata": {},
   "source": [
    "## random模块（伪随机数模块）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "be01d09c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f620ef3f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.923560275492801"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random.random方法： 取(0,1)\n",
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c7882242",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random.randint(a,b),随机生成a-b之间的一个\n",
    "random.randint(1,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "bf70f246",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "5\n",
      "2\n",
      "1\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2cd39d7a",
   "metadata": {},
   "source": [
    "### 课本p35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "616a4529",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "f6eb9526",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "time.sleep(10)\n",
    "print(\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6221a319",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n",
      "This minute seems a little odd.\n",
      "This minute seems a little odd.\n",
      "This minute seems a little odd.\n",
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "\n",
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19,\n",
    "        21, 23, 25, 27, 29, 31, 33, 35, 37,\n",
    "        39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59 ]\n",
    "\n",
    "right_this_minute = datetime.datetime.today() .minute\n",
    "\n",
    "for i in range(5):\n",
    "    if right_this_minute in odds:\n",
    "        print(\"This minute seems a little odd.\")\n",
    "    else:\n",
    "        print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea58c578",
   "metadata": {},
   "source": [
    "### 课本p43"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "057703a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer om the wall.\n",
      "99 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "98 bottles of beer on the wall.\n",
      "\n",
      "98 bottles of beer om the wall.\n",
      "98 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "97 bottles of beer on the wall.\n",
      "\n",
      "97 bottles of beer om the wall.\n",
      "97 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "96 bottles of beer on the wall.\n",
      "\n",
      "96 bottles of beer om the wall.\n",
      "96 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "95 bottles of beer on the wall.\n",
      "\n",
      "95 bottles of beer om the wall.\n",
      "95 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "94 bottles of beer on the wall.\n",
      "\n",
      "94 bottles of beer om the wall.\n",
      "94 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "93 bottles of beer on the wall.\n",
      "\n",
      "93 bottles of beer om the wall.\n",
      "93 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "92 bottles of beer on the wall.\n",
      "\n",
      "92 bottles of beer om the wall.\n",
      "92 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "91 bottles of beer on the wall.\n",
      "\n",
      "91 bottles of beer om the wall.\n",
      "91 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "90 bottles of beer on the wall.\n",
      "\n",
      "90 bottles of beer om the wall.\n",
      "90 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "89 bottles of beer on the wall.\n",
      "\n",
      "89 bottles of beer om the wall.\n",
      "89 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "88 bottles of beer on the wall.\n",
      "\n",
      "88 bottles of beer om the wall.\n",
      "88 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "87 bottles of beer on the wall.\n",
      "\n",
      "87 bottles of beer om the wall.\n",
      "87 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "86 bottles of beer on the wall.\n",
      "\n",
      "86 bottles of beer om the wall.\n",
      "86 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "85 bottles of beer on the wall.\n",
      "\n",
      "85 bottles of beer om the wall.\n",
      "85 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "84 bottles of beer on the wall.\n",
      "\n",
      "84 bottles of beer om the wall.\n",
      "84 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "83 bottles of beer on the wall.\n",
      "\n",
      "83 bottles of beer om the wall.\n",
      "83 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "82 bottles of beer on the wall.\n",
      "\n",
      "82 bottles of beer om the wall.\n",
      "82 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "81 bottles of beer on the wall.\n",
      "\n",
      "81 bottles of beer om the wall.\n",
      "81 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "80 bottles of beer on the wall.\n",
      "\n",
      "80 bottles of beer om the wall.\n",
      "80 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "79 bottles of beer on the wall.\n",
      "\n",
      "79 bottles of beer om the wall.\n",
      "79 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "78 bottles of beer on the wall.\n",
      "\n",
      "78 bottles of beer om the wall.\n",
      "78 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "77 bottles of beer on the wall.\n",
      "\n",
      "77 bottles of beer om the wall.\n",
      "77 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "76 bottles of beer on the wall.\n",
      "\n",
      "76 bottles of beer om the wall.\n",
      "76 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "75 bottles of beer on the wall.\n",
      "\n",
      "75 bottles of beer om the wall.\n",
      "75 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "74 bottles of beer on the wall.\n",
      "\n",
      "74 bottles of beer om the wall.\n",
      "74 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "73 bottles of beer on the wall.\n",
      "\n",
      "73 bottles of beer om the wall.\n",
      "73 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "72 bottles of beer on the wall.\n",
      "\n",
      "72 bottles of beer om the wall.\n",
      "72 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "71 bottles of beer on the wall.\n",
      "\n",
      "71 bottles of beer om the wall.\n",
      "71 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "70 bottles of beer on the wall.\n",
      "\n",
      "70 bottles of beer om the wall.\n",
      "70 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "69 bottles of beer on the wall.\n",
      "\n",
      "69 bottles of beer om the wall.\n",
      "69 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "68 bottles of beer on the wall.\n",
      "\n",
      "68 bottles of beer om the wall.\n",
      "68 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "67 bottles of beer on the wall.\n",
      "\n",
      "67 bottles of beer om the wall.\n",
      "67 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "66 bottles of beer on the wall.\n",
      "\n",
      "66 bottles of beer om the wall.\n",
      "66 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "65 bottles of beer on the wall.\n",
      "\n",
      "65 bottles of beer om the wall.\n",
      "65 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "64 bottles of beer on the wall.\n",
      "\n",
      "64 bottles of beer om the wall.\n",
      "64 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "63 bottles of beer on the wall.\n",
      "\n",
      "63 bottles of beer om the wall.\n",
      "63 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "62 bottles of beer on the wall.\n",
      "\n",
      "62 bottles of beer om the wall.\n",
      "62 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "61 bottles of beer on the wall.\n",
      "\n",
      "61 bottles of beer om the wall.\n",
      "61 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "60 bottles of beer on the wall.\n",
      "\n",
      "60 bottles of beer om the wall.\n",
      "60 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "59 bottles of beer on the wall.\n",
      "\n",
      "59 bottles of beer om the wall.\n",
      "59 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "58 bottles of beer on the wall.\n",
      "\n",
      "58 bottles of beer om the wall.\n",
      "58 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "57 bottles of beer on the wall.\n",
      "\n",
      "57 bottles of beer om the wall.\n",
      "57 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "56 bottles of beer on the wall.\n",
      "\n",
      "56 bottles of beer om the wall.\n",
      "56 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "55 bottles of beer on the wall.\n",
      "\n",
      "55 bottles of beer om the wall.\n",
      "55 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "54 bottles of beer on the wall.\n",
      "\n",
      "54 bottles of beer om the wall.\n",
      "54 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "53 bottles of beer on the wall.\n",
      "\n",
      "53 bottles of beer om the wall.\n",
      "53 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "52 bottles of beer on the wall.\n",
      "\n",
      "52 bottles of beer om the wall.\n",
      "52 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "51 bottles of beer on the wall.\n",
      "\n",
      "51 bottles of beer om the wall.\n",
      "51 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "50 bottles of beer on the wall.\n",
      "\n",
      "50 bottles of beer om the wall.\n",
      "50 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "49 bottles of beer on the wall.\n",
      "\n",
      "49 bottles of beer om the wall.\n",
      "49 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "48 bottles of beer on the wall.\n",
      "\n",
      "48 bottles of beer om the wall.\n",
      "48 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "47 bottles of beer on the wall.\n",
      "\n",
      "47 bottles of beer om the wall.\n",
      "47 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "46 bottles of beer on the wall.\n",
      "\n",
      "46 bottles of beer om the wall.\n",
      "46 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "45 bottles of beer on the wall.\n",
      "\n",
      "45 bottles of beer om the wall.\n",
      "45 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "44 bottles of beer on the wall.\n",
      "\n",
      "44 bottles of beer om the wall.\n",
      "44 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "43 bottles of beer on the wall.\n",
      "\n",
      "43 bottles of beer om the wall.\n",
      "43 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "42 bottles of beer on the wall.\n",
      "\n",
      "42 bottles of beer om the wall.\n",
      "42 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "41 bottles of beer on the wall.\n",
      "\n",
      "41 bottles of beer om the wall.\n",
      "41 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "40 bottles of beer on the wall.\n",
      "\n",
      "40 bottles of beer om the wall.\n",
      "40 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "39 bottles of beer on the wall.\n",
      "\n",
      "39 bottles of beer om the wall.\n",
      "39 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "38 bottles of beer on the wall.\n",
      "\n",
      "38 bottles of beer om the wall.\n",
      "38 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "37 bottles of beer on the wall.\n",
      "\n",
      "37 bottles of beer om the wall.\n",
      "37 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "36 bottles of beer on the wall.\n",
      "\n",
      "36 bottles of beer om the wall.\n",
      "36 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "35 bottles of beer on the wall.\n",
      "\n",
      "35 bottles of beer om the wall.\n",
      "35 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "34 bottles of beer on the wall.\n",
      "\n",
      "34 bottles of beer om the wall.\n",
      "34 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "33 bottles of beer on the wall.\n",
      "\n",
      "33 bottles of beer om the wall.\n",
      "33 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "32 bottles of beer on the wall.\n",
      "\n",
      "32 bottles of beer om the wall.\n",
      "32 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "31 bottles of beer on the wall.\n",
      "\n",
      "31 bottles of beer om the wall.\n",
      "31 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "30 bottles of beer on the wall.\n",
      "\n",
      "30 bottles of beer om the wall.\n",
      "30 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "29 bottles of beer on the wall.\n",
      "\n",
      "29 bottles of beer om the wall.\n",
      "29 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "28 bottles of beer on the wall.\n",
      "\n",
      "28 bottles of beer om the wall.\n",
      "28 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "27 bottles of beer on the wall.\n",
      "\n",
      "27 bottles of beer om the wall.\n",
      "27 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "26 bottles of beer on the wall.\n",
      "\n",
      "26 bottles of beer om the wall.\n",
      "26 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "25 bottles of beer on the wall.\n",
      "\n",
      "25 bottles of beer om the wall.\n",
      "25 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "24 bottles of beer on the wall.\n",
      "\n",
      "24 bottles of beer om the wall.\n",
      "24 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "23 bottles of beer on the wall.\n",
      "\n",
      "23 bottles of beer om the wall.\n",
      "23 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "22 bottles of beer on the wall.\n",
      "\n",
      "22 bottles of beer om the wall.\n",
      "22 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "21 bottles of beer on the wall.\n",
      "\n",
      "21 bottles of beer om the wall.\n",
      "21 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "20 bottles of beer on the wall.\n",
      "\n",
      "20 bottles of beer om the wall.\n",
      "20 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "19 bottles of beer on the wall.\n",
      "\n",
      "19 bottles of beer om the wall.\n",
      "19 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "18 bottles of beer on the wall.\n",
      "\n",
      "18 bottles of beer om the wall.\n",
      "18 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "17 bottles of beer on the wall.\n",
      "\n",
      "17 bottles of beer om the wall.\n",
      "17 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "16 bottles of beer on the wall.\n",
      "\n",
      "16 bottles of beer om the wall.\n",
      "16 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "15 bottles of beer on the wall.\n",
      "\n",
      "15 bottles of beer om the wall.\n",
      "15 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "14 bottles of beer on the wall.\n",
      "\n",
      "14 bottles of beer om the wall.\n",
      "14 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "13 bottles of beer on the wall.\n",
      "\n",
      "13 bottles of beer om the wall.\n",
      "13 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "12 bottles of beer on the wall.\n",
      "\n",
      "12 bottles of beer om the wall.\n",
      "12 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "11 bottles of beer on the wall.\n",
      "\n",
      "11 bottles of beer om the wall.\n",
      "11 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "10 bottles of beer on the wall.\n",
      "\n",
      "10 bottles of beer om the wall.\n",
      "10 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "9 bottles of beer on the wall.\n",
      "\n",
      "9 bottles of beer om the wall.\n",
      "9 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "8 bottles of beer on the wall.\n",
      "\n",
      "8 bottles of beer om the wall.\n",
      "8 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "7 bottles of beer on the wall.\n",
      "\n",
      "7 bottles of beer om the wall.\n",
      "7 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "6 bottles of beer on the wall.\n",
      "\n",
      "6 bottles of beer om the wall.\n",
      "6 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "5 bottles of beer on the wall.\n",
      "\n",
      "5 bottles of beer om the wall.\n",
      "5 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "4 bottles of beer on the wall.\n",
      "\n",
      "4 bottles of beer om the wall.\n",
      "4 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "3 bottles of beer on the wall.\n",
      "\n",
      "3 bottles of beer om the wall.\n",
      "3 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "2 bottles of beer on the wall.\n",
      "\n",
      "2 bottles of beer om the wall.\n",
      "2 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "1 bottle of beer on the wall.\n",
      "\n",
      "1 bottle of beer om the wall.\n",
      "1 bottle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "No more bottles of beer on the wall.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"\n",
    "for bear_num in range(99,0,-1):\n",
    "    print(bear_num, word, \"of beer om the wall.\")\n",
    "    print(bear_num, word, \"of beer.\")\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around.\")\n",
    "    if bear_num == 1:\n",
    "        print(\"No more bottles of beer on the wall.\")\n",
    "    else:\n",
    "        new_num = bear_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word, \"of beer on the wall.\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a193d64a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
